//1.导入VueRouter
import Vue from "vue";
import VueRouter from 'vue-router'
import home from "@/components/views/home/HomePage.vue";
import ServiceError from '@/components/global/ServiceError.vue'
import DevTools from "@/components/views/devtools/EtnorDevTools.vue"
import DashboardPage from "@/components/admin/home/DashboardPage.vue"
import NotFound from "@/components/views/NotFound.vue"
import ApiManagement from "@/components/admin/basemanagement/ApiManagement.vue"
import ApiAdd from "@/components/admin/basemanagement/ApiAdd.vue"
import LogManagement from "@/components/admin/basemanagement/LogManagement.vue"
import UserManagement from "@/components/admin/systemmanagement/UserManagement.vue"
import ApiReview from "@/components/admin/basemanagement/ApiReview.vue"
import PendingReview from "@/components/admin/basemanagement/PendingReview.vue"
import Empic from "@/components/admin/EmpicCheck.vue"
import FeedbackPage from "@/components/views/home/FeedbackPage.vue"
import ApiDetail from "@/components/views/home/ApiDetails.vue"
import CreatorProfile from '@/components/views/home/CreatorProfile.vue'; // 引入组件
import ControlCenter from '@/components/admin/phone/views/ControlCenter.vue'; 
import ArticleDetail from '@/components/admin/phone/views/ArticleDetail.vue'; // 引入新组件
import AnnouncementDetail from '@/components/admin/phone/views/AnnouncementDetail.vue'

import RestApiDoc from '@/components/admin/phone/views/docs/RestApiDoc.vue'
import WebSocketDoc from '@/components/admin/phone/views/docs/WebSocketDoc.vue'
import MyApi from '@/components/admin/phone/views/MyApi.vue'

import SdkDoc from '@/components/admin/phone/views/docs/SdkDoc.vue'
// 导入政策相关页面
const PrivacyPolicy = () => import('@/components/views/policy/PrivacyPolicy.vue')
const Terms = () => import('@/components/views/policy/Terms.vue')
const CookiePolicy = () => import('@/components/views/policy/CookiePolicy.vue')
//解决vue-router重复点击报错问题
const routerPush = VueRouter.prototype.push;
 
VueRouter.prototype.push = function (location) {
 
    return routerPush.call(this, location).catch(err => {})
 
};
//2.使用路由
Vue.use(VueRouter);
//3.创建VueRouter的实例
const router = new VueRouter({
    //tips:不想要 #（锚点）就添加下面代码
    mode: 'hash',

    //4.配置路由的path和组件
    routes :[
      //前端博客文章
      {
        path: '/doc/article/:articleId/:language',
        name: 'blogDetail',
        component: () => import("@/components/admin/phone/views/ArticleFont.vue"),
        },
      //手机端管理系统
      {
        path: "/admin/mobile",
        name: 'adminMobile',
        component: () => import("@/components/admin/phone/HomePage.vue"),
        meta: { title: '手机端管理系统' },
        children: [
          {
            path: '/control-center',
            name: 'controlCenter',
            component: ControlCenter,
            meta: { title: '控制中心' }
          },
          {
            path: '/add-interface',
            name: 'addInterface',
            component: () => import('@/components/admin/phone/views/InterfaceManagement.vue'),
            meta: { title: '接口管理' }
          },
          {
            path: '/api-review',
            name: 'apiReview',
            component: () => import('@/components/admin/phone/views/ApiReview.vue'),
            meta: { title: '接口审核' }
          },
          
          {
            path: '/tender-request',
            name: 'tenderRequest',
            component: () => import('@/components/admin/phone/views/TenderRequest.vue'),
            meta: { title: '招标请求' }
          
          },
          {
            path: '/my-api',
            name: 'myApi',
            component: MyApi,
            meta: { title: '我的API' }
          },
          {
            path:'/developer-center',
            name:'EtnorAPIAdminDoc',
            component: () => import('@/components/admin/phone/views/EtnorAPIAdminDoc.vue'),
            meta: { title: '开发者中心' }
          },
          {
            path: '/article/:id', // 动态路由用来获取文章详情
            component: ArticleDetail,

            props: true,
          },
          {
            path: '/integratedApi/create',
            name: 'integratedApi',
            component: () => import('@/components/admin/phone/views/intergratedApi.vue'),
        },
         
          {
            path:'/user/info',
            name:'userInfo',
            component: () => import('@/components/admin/phone/views/UserDetails.vue'),
            meta: { title: '用户信息' }
          
            
          },
          {
            path: '/doc/article/edit/:articleId/:language',
            name: 'editArticle',
            component: () => import('@/components/admin/phone/views/RichEditorText.vue'),
            meta: { title: '编辑文章' }
          },
          {
            path: '/blog',
            name: 'blog',
            component: () => import('@/components/admin/phone/views/BlogManagement.vue'),
            meta: { title: '博客管理' }
          },
          {
            path:'/blog/createBlog',
            name:'createBlog',
            component: () => import('@/components/admin/phone/views/AddBlog.vue'),
          },{
            path: '/support',
            name: 'support',
            component: () => import('@/components/admin/phone/views/Support.vue'),
          }
           ,
           {
            path: '/bug-center',
            name: 'bugCenter',
            component: () => import('@/components/admin/phone/views/BugCenter.vue'),
            meta: { title: '缺陷中心' }
          }

          
          
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
          
        ]
       
      },
      
      
      { path: '/creator/:id', component: CreatorProfile }, // 动态路由
      {
        path: "/feedback",
        name:'feedback',
        component: FeedbackPage,

      },
      
      {
        path: "/api/Details/:id",
        name:'apiDetail',
        component: ApiDetail,
      },
      {
        path: "/empic",
        component: Empic
      },
        {
          path: "/home",
          name:'home',
          component: home,
        },
        
        {
          path: "/about",
          name:'anout',
          component: () => import("@/components/views/about/aboutUs.vue"),
        },
        {
          path: "/watch",
          name:'watch',
          component: () => import("@/components/views/watch/WatchApi.vue"),
        },
        {
          path: '/article', // 动态路由用来获取文章详情
          component: () => import('@/components/admin/phone/views/ArticleRead.vue'),
        },
        {
            path: '/',
            redirect: '/home',
          },
          {
            path: "/tools",
            name:'tools',
            component: () => import("@/components/views/tools/apiTools.vue"),
          },
          {
            path: "/ditails",
            name:'ditails',
            component: () => import("@/components/views/personalHome.vue"),
          },
          {
            path: "/developerTalk",
            name:'developerTalk',
            component: () => import("@/components/views/about/developerSay.vue"),
          },
          {
            path: "/english",
            name:'english',
            component: () => import("@/components/views/indexPage.vue"),
          },
          {
            
            path: "/privacy",
            name:'PrivacyPolicy',
            component: () => import('@/components/views/policy/PrivacyPolicy.vue'),
            meta: { title: '隐私政策' }
          },
          {
            path: '/terms',
            name: 'Terms',
            component: Terms,
            meta: { title: '服务条款' }
          },
          {
            path: '/cookie-policy',
            name: 'CookiePolicy',
            component: CookiePolicy,
            meta: { title: 'Cookie政策' }
          },
          {
            path: '/service-error',
            name: 'ServiceError',
            component: ServiceError,
          },

          {
            path: '/devtools',
            // name: 'devtools',
            component: DevTools,
          },
          {
            path: '/dashboard',
            name: 'DashboardPage',
            component: DashboardPage,
            //二级路由
            children: [
              {
                path: '/',
                redirect: '/apimanagement'
              },
              {
                path: '/apimanagement',
                name: 'apimanagement',
                component: ApiManagement,
                meta: { title: 'API管理' }
              },
              {
                path: '/apiAdd',
                name: 'apiAdd',
                component: ApiAdd,
                meta: { title: '新增API' }
              },
              {
                path: '/logmanagement',
                name: 'logmanagement',
                component: LogManagement,
                meta: { title: '日志管理' }
              },
              {
                path: '/usermanagement',
                name: 'usermanagement',
                component: UserManagement,
                meta: { title: '用户管理' }
              },
              {
                path: '/apireview',
                name: 'apireview',
                component: ApiReview,
                meta: { title: '审核/上线' }
              },
              {
                path: '/pendingreview',
                name: 'pendingreview',
                component: PendingReview,
                meta: { title: '我的审核' }
              },
              {
                path: '/interfacealert',
                name: 'interfacealert',
                component: () => import('@/components/admin/git/indexPage.vue'),
                meta: { title: '接口告警' }
              },{
                path: '/problemfeedback',

                name: 'problemfeedback',
                component: () => import('@/components/admin/problem/ProblemShow.vue'),
                meta: { title: '问题反馈' }
              },{
                path: '/policymanagement',
                name: 'policymanagement',
                component: () => import('@/components/admin/systemmanagement/PolicyManagement.vue'),
                meta: { title: '政策管理' }
              },{
                path: '/mybug',

                name:'mybug',
                component: () => import('@/components/admin/problem/MyBug.vue'),
              },
             
              
              
            ]
          },
          {
            path:'/login',
            component: () => import('@/components/admin/login/LoginPage.vue')
          },
          {
            path: '/test',
            component: () => import('@/components/views/personalHome.vue')
          },
          {
            path: '/help',
            name: 'HelpCenter',
            component: () => import('@/components/views/help/HelpCenter.vue')
          },
          {
            path: '/community',
            name: 'DeveloperCommunity',
            component: () => import('@/components/views/community/DeveloperCommunity.vue'),
            meta: { title: '开发者社区' }
          },
          {
            path: '/announcement-detail',
            name: 'AnnouncementDetail',
            component: AnnouncementDetail,
            meta: {
              title: '公告详情',
              requireAuth: true
            }
          },
          {
            path: '/docs/rest-api',
            name: 'RestApiDoc',
            component: RestApiDoc
          },
          {
            path: '/docs/websocket',
            name: 'WebSocketDoc',
            component: WebSocketDoc
          },
          {
            path: '/docs/sdk',
            name: 'SdkDoc',
            component: SdkDoc
          }
         
         
      ]
})
//5.导入路由实例
export default router

